/*
 * 文件名：DBHelper.java
 * 版权：Copyright by Power7000 Team
 * 描述：
 * 修改人：yangyangyang
 * 修改时间：2017年1月17日
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */
package com.core;  
import java.sql.Connection;  
import java.sql.DriverManager;  
import java.sql.PreparedStatement;  
import java.sql.SQLException;  
import java.sql.Statement;

import com.util.DeployPropertiesUtil;

  
public class DBHelper {  
    public static  String url = null;  
    public static  String driver = null;  
    public static  String user = null;  
    public static  String password = null;  
  
    public Connection conn = null;  
    public Statement  pst = null;  
  
    public DBHelper() {  
        final DeployPropertiesUtil utils = new DeployPropertiesUtil();
        driver=utils.readPropertyByNameFromProperties("dataSource.driver");
        url=utils.readPropertyByNameFromProperties("dataSource.url");
        user=utils.readPropertyByNameFromProperties("dataSource.username");
        password=utils.readPropertyByNameFromProperties("dataSource.password");
        try {  
            Class.forName(driver);//指定连接类型  
            conn = DriverManager.getConnection(url, user, password);//获取连接  
            pst = conn.createStatement();//准备执行语句  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
    }  
  
    public void close() {  
        try {  
            this.conn.close();  
            this.pst.close();  
        } catch (SQLException e) {  
            e.printStackTrace();  
        }  
    }  
}  

